﻿using PushBox.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace PushBox.WpfView
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Map m;

        public MainWindow()
        {
            InitializeComponent();

            string str = @"
 #######
##     #
##  +  #
#   ** +#
#  @    #
#       #
#########
";
            m = new Map(str);
            m.DoDraw = DrawMap;
            m.DoDraw(m);
        }

        private void DrawMap(Map map)
        {
            for (int y = 0; y < map.Height; y++)
            {
                for (int x = 0; x < map.Width; x++)
                {
                    Position p = map.GetObject(x, y);
                    if (p is Box) Console.Write("*");
                    else if (p is Wall) Console.Write("#");
                    else if (p is Person)
                    {
                        Image person = new Image();
                        person.Source = new BitmapImage(new Uri(@"/img/p-d.png", UriKind.Relative));
                        person.Margin = new Thickness(p.X * 32, p.Y * 32, 0, 0);
                        person.RenderSize = new Size(32, 32);
                        this.grid.Children.Add(person);
                    }
                    else if (p is Core.Key) Console.Write("+");
                    else Console.Write(" ");
                }
                Console.WriteLine();
            }
        }
    }
}
